<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

/**
 * @author Меркулов Илья aka Bit0reZ
 * @license GNU GPLv3
 */

/**
 * @package JS helper
 */

function js_dir()
{
        $CI = &get_instance();
        return $CI->config->item('js_dir');
}

function jquery($latest = false)
{
        $CI = &get_instance();
        if(!$latest)
                return $CI->config->item('jquery');
        else
                return $CI->config->item('jquery_latest');
}

function jquery_ui()
{
        $CI = &get_instance();
        return $CI->config->item('jquery_ui');
}

function jquery_url($latest = false)
{
        $CI = &get_instance();
        if(!$latest)
                return $CI->config->item('base_url').$CI->config->item('js_dir').'/'.
                        $CI->config->item('jquery');
        else
                return $CI->config->item('base_url').$CI->config->item('js_dir').'/'.
                        $CI->config->item('jquery_latest');
}

function jquery_ui_url()
{
        $CI = &get_instance();
        return $CI->config->item('base_url').$CI->config->item('js_dir').'/'.
                $CI->config->item('jquery_ui');
}

/**
 * @package CSS helper
 */

function main_style_url()
{
        $CI = &get_instance();
        return $CI->config->item('base_url').$CI->config->item('css_dir').'/'.
                $CI->config->item('main_style');
}

function jquery_ui_style_url()
{
        $CI = &get_instance();
        return $CI->config->item('base_url').$CI->config->item('css_dir').'/'.
                $CI->config->item('jquery_ui_style');
}

function wisywig_load()
{
        $CI = &get_instance();
        $base_url = $CI->config->item('base_url');
        $ww_name = $CI->config->item('wisywig');
        $ww = $CI->config->item($ww_name);
        $cont = '';
        foreach($ww['js'] as $val)
        {
                $cont .= '<script type="text/javascript" src="'.$base_url.
                        $ww['dir'].$val.'"></script>'."\n";
        }
        if($ww['css'] != '')
        {
                $css_dir = $CI->config->item('css_dir');
                $cont .= '<link rel="stylesheet" href="'.
                        $base_url.$css_dir.
                        $ww['css'].'" type="text/css" />';
        }
        return $cont;
}
?>
